<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*, java.util.*" %>

<% request.setCharacterEncoding("euc-kr"); %>


<jsp:include page="header.jsp"/>

<jsp:include page="aside_menu.jsp"/> 
<script type="text/javascript">
	function Check(){
		if(Form.keyword.value.length<1){
			alert("검색어입력하세요");
			Form.keyword.focus();
			return false;
		}
	}
</script>
</head>
<body>

	<article>
<%
String key=request.getParameter("Key");
String keyword=request.getParameter("keyword");
String pageNum = request.getParameter("pageNum");
if(pageNum == null)
{
	pageNum = "1";
}

int listSize = 10;
int currentPage = Integer.parseInt(pageNum);
int StartRow = currentPage * listSize - listSize;
int endRow=StartRow+listSize-1;
int maxRow;

Class.forName("com.mysql.jdbc.Driver");

Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String strSQL="";
try{
	String jdbcDriver ="jdbc:mysql://192.168.0.120:3306/coffee?" +
			"useUnicode=true&characterEncoding=euckr";
String dbUser="root";
String dbPass="123456";

	
	conn = DriverManager.getConnection(jdbcDriver, dbUser, dbPass);
	strSQL="select * from cake_table where num between ? and ? ";
	
	pstmt = conn.prepareStatement(strSQL);
	pstmt.setInt(1, StartRow);
	pstmt.setInt(2, endRow);
	
	rs=pstmt.executeQuery();
	
	
	
	
	/* if(key==null || keyword==null){
	strSQL="select * from RVboard order by num DESC";
	}else{
	strSQL="select count(*) From RVboard where "+key+"like '%"+keyword+"%'";
} */
	//rs = stmt.executeQuery(strSQL);
%>


<div id="list">

<table width="700">

<%

	for(int i=0; i<listSize; i++){
		int j=0;
		
	%>
	<tr>
	<%
	for(j=0; j<3; j++){
		if(rs.next()){
			int listnum=rs.getInt("num");
			String name=rs.getString("name");
			String filename=rs.getString("filename");
		%>
		<td>
		<table bgcolor='#fffff' cellspacing="20" cellpadding="7" >
			
			<tr>
				<td align="center">
					<a href=cake_output.jsp?num=<%=listnum %>>
					<img src=<%="images/"+filename%>
							width="200" height="200">
				</td>
			</tr>
			<tr>
				<td align="center" width="170">
				<%=name %>
				</td>
			</tr>

		</table>
			</td>
			
			<%
		
		}
	}
	i=i+j;

%>
</tr>
<%
	}
%>

</td>
	<!-- <td align="right">
	<a href="admin_cakewrite.jsp">[등록]</a>
	</td> -->
</tr>
</table>


<%

int setPage=1;
int lastPage=0;



while(setPage <= lastPage)
{
%>
	<a href="menu02.jsp?pageNum=<%=setPage %>">[<%=setPage %>]
	</a>
<%	
	setPage = setPage + 1;
}

}catch(SQLException ex){
	out.println(ex.getMessage());
}finally{
	if(rs != null) try{rs.close();} catch(SQLException ex){}
	if(pstmt != null) try{pstmt.close();} catch(SQLException ex){}
	if(conn != null) try{conn.close();} catch(SQLException ex){}
}

%>

</body>
</article>
</div>
<jsp:include page="footer.jsp"/>